package com.guoheng.hazard.sys.controller.entpr;

import com.guoheng.hazard.common.base.Result;
import com.guoheng.hazard.sys.model.dto.entpr.StorageRoomInsertDTO;
import com.guoheng.hazard.sys.model.dto.entpr.StorageRoomUpdateDTO;
import com.guoheng.hazard.sys.service.entpr.StorageRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * 类功能描述:　StorageRoomController
 *
 * @author fbl
 * @date 2019-11-12 18:13
 */
@RestController
@Validated
@Api(value = "企业库房信息")
public class StorageRoomController {

    @Resource
    StorageRoomService storageRoomService;

    @ApiOperation(value = "查询企业库房信息列表")
    @GetMapping(value = "data/basic/enterprise/rooms")
    public Result getEntprRooms(String entprName, String roomNo, Long entprId, @RequestParam(value = "pageNum") Integer pageNum, @RequestParam(value = "pageSize") Integer pageSize) {
        return storageRoomService.getEntprRooms(entprName, roomNo, entprId, pageNum, pageSize);
    }

    @ApiOperation(value = "修改企业库房信息列表")
    @PutMapping(value = "data/basic/enterprise/rooms")
    public Result updateEntprRooms(@RequestBody @Valid StorageRoomUpdateDTO storageRoomUpdateDTO) {
        return storageRoomService.updateEntprRooms(storageRoomUpdateDTO);
    }

    @ApiOperation(value = "新增企业库房信息列表")
    @PostMapping(value = "data/basic/enterprise/rooms")
    public Result insertEntprRooms(@RequestBody @Valid StorageRoomInsertDTO storageRoomInsertDTO) {
        return storageRoomService.insertEntprRooms(storageRoomInsertDTO);
    }

    @ApiOperation(value = "删除企业库房信息列表")
    @DeleteMapping(value = "data/basic/enterprise/rooms/{id}")
    public Result deleteEntprRooms(@PathVariable @NotNull Long id) {
        return storageRoomService.deleteEntprRooms(id);
    }

    @ApiOperation(value = "查询企业库房信息详情")
    @GetMapping(value = "data/basic/enterprise/rooms/{id}")
    public Result getEntprRoomById(@PathVariable @NotNull Long id) {
        return storageRoomService.getEntprRoomById(id);
    }
}